package com.gress.shop.annotation.aspect;//package com.twodfire.boss.tool.annotation.aspect;
//
//import com.alibaba.fastjson.JSON;
//import com.twodfire.logger.Logger;
//import com.twodfire.logger.LoggerFactory;
//import org.apache.commons.lang3.StringUtils;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.springframework.stereotype.Component;
//
//import java.util.HashMap;
//import java.util.Map;
//
///**
// * Created with IntelliJ IDEA.
// * User:jiandan
// * Date:2016/4/14.
// * Time:14:14.
// * INFO:用于监控 BossCenter 的慢接口
// */
//
////@Aspect
////@Component
//public class BossToolCenterAspect {
////    private static final Logger longTimeLogger = LoggerFactory.longTimeLogger;
//    private static final int MS_THRESHOLD = 200;//毫秒阈值
//
////    @Around("execution(public * com.twodfire.boss.tool.service..*(..))")
//    public Object aroundService(ProceedingJoinPoint pjp) throws Throwable {
//        return longTimeLog(pjp, MS_THRESHOLD);
//    }
//
//    /**
//     * 记录方法的时间
//     *
//     * @param pjp      ProceedingJoinPoint
//     * @param longTime 超时需记录日志的时间
//     * @return 执行结果
//     * @throws Throwable 异常
//     */
//    private Object longTimeLog(ProceedingJoinPoint pjp, int longTime) throws Throwable {
//        Map<String, Object> alertInfo = new HashMap<>();
//        long start = System.currentTimeMillis();
//        Object rs = pjp.proceed();
//        long escape = System.currentTimeMillis() - start;
//        alertInfo.put("escape", escape);
//        StringBuilder sb;
//        if (escape >= longTime) {
//            sb = new StringBuilder(128);
//            sb.append(pjp.getSignature().getDeclaringTypeName());
//            sb.append(" ");
//            sb.append(pjp.getSignature().getName());
//            alertInfo.put("interfaceInfo", sb.toString());
//            // 添加方法的参数, 方便调试
//            Object[] params = pjp.getArgs();
//            if (params != null && params.length > 0) {
//                //kibana 不支持多类型数组,参数处理成字符串
//                String paramsStr = JSON.toJSONString(params);
//                paramsStr = StringUtils.replace(paramsStr, "\"", "");
//                alertInfo.put("params", paramsStr);
//            }
//            System.out.println(alertInfo);
////            longTimeLogger.info(alertInfo, "");
//        }
//        return rs;
//    }
//
//
//}
